package com.tanhua.server.service.impl;

import com.tanhua.dubbo.api.UserLocationApi;
import com.tanhua.model.dto.UserLocationDto;
import com.tanhua.model.vo.ErrorResult;
import com.tanhua.server.exception.BusinessException;
import com.tanhua.server.interceptor.UserHolder;
import com.tanhua.server.service.BaiduService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

/**
 * @author wjs
 * @version 1.0
 * @date 2022/1/1 0001 下午 9:51
 */

@Service
public class BaiduServiceImpl implements BaiduService {
    @DubboReference
    private UserLocationApi userLocationApi;

    @Override
    public void updateLocation(UserLocationDto dto) {
        dto.setUserId(UserHolder.getUserId());
        Boolean flag = userLocationApi.updateLocation(dto);
        if(!flag) {
            throw  new BusinessException(ErrorResult.error());
        }
    }
}
